[##include file="common/header.tpl.php"##]
[##include file="common/nav.tpl.php"##]
<div id="main">
	<p>
    <form id="mapadd_form" name="mapadd_form" method="post" style="margin-top:20px;" >
    地图 I D：<input type="text" name="id" id="id" value="[##$list.id##]" readonly><br />
    地图名称：<input type="text" name="map_name" id="map_name" value="[##$list.name##]" readonly><br />
    地图大小：<input type="text" name="map_size" id="map_size" value="[##$list.map_size##]" readonly><br>
    地图坐标：<input type="text" name="map_xy" id="map_xy" value="([##$x##],[##$y##])" readonly><br>
    地图设置：<select name="map" onclick="simOptionClick()" >
    <option value="1" onclick="showOptionValue( this )" [##if $list['map'][$x][$y]['map'] == 1##]selected="selected"[##/if##]>围墙</option>
    <option value="8" onclick="showOptionValue( this )" [##if $list['map'][$x][$y]['map'] == 8##]selected="selected"[##/if##]>人物</option>
    <option value="9" onclick="showOptionValue( this )" [##if $list['map'][$x][$y]['map'] == 9##]selected="selected"[##/if##]>通道</option>
    <option value="2" onclick="showOptionValue( this )" [##if $list['map'][$x][$y]['map'] == 2##]selected="selected"[##/if##]>河流</option>
    <option value="3" onclick="showOptionValue( this )" [##if $list['map'][$x][$y]['map'] == 3##]selected="selected"[##/if##]>绿洲</option>
    <option value="4" onclick="showOptionValue( this )" [##if $list['map'][$x][$y]['map'] == 4##]selected="selected"[##/if##]>美女</option>		
    <option value="5" onclick="showOptionValue( this )" [##if $list['map'][$x][$y]['map'] == 5##]selected="selected"[##/if##]>武将</option>
    </select><br>
    <div id="rivers" style="[##if $list['map'][$x][$y]['map'] == 2 || $list['map'][$x][$y]['map'] == 3 || $list['map'][$x][$y]['map'] == 9 || $list['map'][$x][$y]['map'] == 8##]display:inline;[##else##]display:none;[##/if##]">
     <table class="form_table">
     	<tr>
        	<td>
            	文字
            </td>
        	<td>
    			<textarea name="content" id="content" style="width:600px; height:100px;">[##if !empty($list['map'][$x][$y]['content'])##][##$list['map'][$x][$y]['content']##][##/if##]</textarea>
     		</td>
        </tr>
        <tr>
        	<td>赏罚<input type="checkbox" name="select" id="select"  value="1" [##if !empty($list['map'][$x][$y]['function'])##]checked="checked"[##/if##]/></td>
        	<td>
            	<select onchange=changeselect1(this.value) name="map_scene" >
                	<option value="0">请选择</option>
                    <option value="1" [##if !empty($list['map'][$x][$y]['map_scene'])##][##if $list['map'][$x][$y]['map_scene'] == 1##]selected="selected"[##/if##][##/if##]>毒瘴</option>
                    <option value="2" [##if !empty($list['map'][$x][$y]['map_scene'])##][##if $list['map'][$x][$y]['map_scene'] == 2##]selected="selected"[##/if##][##/if##]>宝箱</option>
                    <option value="3" [##if !empty($list['map'][$x][$y]['map_scene'])##][##if $list['map'][$x][$y]['map_scene'] == 3##]selected="selected"[##/if##][##/if##]>机关</option>
                </select>
            	<select name="map_function" >
                	<OPTION selected>请选择</OPTION>
                    [##if !empty($list['map'][$x][$y]['map_function'])##]<option value="[##$list['map'][$x][$y]['map_function']##]" selected="selected">[##if $list['map'][$x][$y]['map_function'] == 1##]血量[##/if##][##if $list['map'][$x][$y]['map_function'] == 2##]筹码[##/if##][##if $list['map'][$x][$y]['map_function'] == 3##]道具[##/if##]</option>[##/if##]
                </select>
                 额度(或ID) 
    			<input type="text" name="function" id="function" value="[##if !empty($list['map'][$x][$y]['function'])##][##$list['map'][$x][$y]['function']##][##/if##]">
     		</td>
        </tr>
     </table>
    </div>
     <div id="general" style="[##if $list['map'][$x][$y]['map'] == 5##]display:inline;[##else##]display:none;[##/if##]">
     武将攻击力:MIN <select name="ap_min" >
                	<option value="-1" >选择</option>
                    [##foreach from=$ap item=item##]
                    <option value="[##$item##]" [##if !empty($list['map'][$x][$y]['ap_min'])##][##if $list['map'][$x][$y]['ap_min'] == $item##]selected="selected"[##/if##][##/if##]>[##$item##]</option>
                    [##/foreach##]
                  </select>
               MAX <select name="ap_max" >
                	<option value="-1" >选择</option>
                    [##foreach from=$ap item=item##]
                    <option value="[##$item##]" [##if !empty($list['map'][$x][$y]['ap_max'])##][##if $list['map'][$x][$y]['ap_max'] == $item##]selected="selected"[##/if##][##/if##]>[##$item##]</option>
                    [##/foreach##]
                  </select>
                <br  />
     <input type="checkbox" name="general" id="general" value="2" [##if !empty($list['map'][$x][$y]['general_id'])##]checked="checked"[##/if##]/>
     指定武将(ID):<input type="text" name="general_id" id="general_id" value="[##if !empty($list['map'][$x][$y]['general_id'])##][##$list['map'][$x][$y]['general_id']##][##/if##]"><br>
    </div>
    <div id="belle" style="[##if $list['map'][$x][$y]['map'] == 4##]display:inline;[##else##]display:none;[##/if##]">
     美女(ID):<input type="text" name="belle_id" id="belle_id" value="[##if !empty($list['map'][$x][$y]['belle_id'])##][##$list['map'][$x][$y]['belle_id']##][##/if##]"><br>
    </div>
    <div style="display:none;">
     <input type="text" name="x" id="x" value="[##$x##]">
     <input type="text" name="y" id="y" value="[##$y##]">
    </div>
    <input type="button" value="修改" id="mapadd_submit" style="padding:5px 20px; font-weight:bold;" />
  </form>
  围墙<span style="background-color:#666;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;人物<span style="background-color:#FF0">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;通道<span style="background-color:#FFF">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;河流<span style="background-color:#06F;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;绿洲<span style="background-color:#0C0;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;美女<span style="background-color:#F00;">&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;武将<span style="background-color:#C96;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
  </p>
</div>
<script type="text/javascript">
// 绑定表单提交事件
$('#mapadd_submit').click(function(id) {
	var submit_url = '[##$adminurl##]/?m=kingdomslady&a=mapschange';
	
	$.post(submit_url , $('#mapadd_form').serialize() , function(d) {
		if(d.code) return alert(d.msg);

		alert(d.msg);
		javascript:history.go(-1);
		//window.location.href = '?m=kingdomslady&a=mapalter';
	} , 'json');

});
function simOptionClick(){      
     var evt=window.event   ;      
     var selectObj=evt?evt.srcElement:null;      
    // IE Only      
    if (evt && selectObj &&   evt.offsetY && evt.button!=2      
         && (evt.offsetY > selectObj.offsetHeight || evt.offsetY<0 ) ) {      
                  
            // 记录原先的选中项      
             var oldIdx = selectObj.selectedIndex;      
     
             setTimeout(function(){      
                 var option=selectObj.options[selectObj.selectedIndex];      
                // 此时可以通过判断 oldIdx 是否等于 selectObj.selectedIndex      
                // 来判断用户是不是点击了同一个选项,进而做不同的处理.      
                 showOptionValue(option)      
     
             }, 60);      
     }      
}      
     
function showOptionValue(opt,msg){      
   // var showValue = document.getElementById('showValue')  
    // resultZone.style.margin="10px";
	if (opt.value == 1){
		 document.getElementById('rivers').style.display ="none";
		 document.getElementById('belle').style.display ="none";
		 document.getElementById('general').style.display ="none";
	}
	if (opt.value == 2 || opt.value == 3 || opt.value == 9 || opt.value == 8){
		 document.getElementById('rivers').style.display ="inline";
		 document.getElementById('belle').style.display ="none";
		 document.getElementById('general').style.display ="none";
		 if(opt.value == 8){
		 	document.getElementById('content').innerHTML='这里就是清风寨么...'; 
		 }else if(opt.value == 3){
			document.getElementById('content').innerHTML='这是一片'+opt.text+'!!!'; 
		 }else{
			document.getElementById('content').innerHTML='这是一条'+opt.text+'!!!'; 	 
		 }
	} 
	if (opt.value == 4){
		document.getElementById('rivers').style.display ="none";
		document.getElementById('general').style.display ="none";
		document.getElementById('belle').style.display ="inline";
	}
	if (opt.value == 5){
		document.getElementById('rivers').style.display ="none";
		document.getElementById('belle').style.display ="none";
		document.getElementById('general').style.display ="inline";
	}    
     //showValue.innerHTML=opt.text;      general
}      
var subcat = new Array();
subcat[0] = new Array('1','血量',1)

subcat[1] = new Array('2','血量',1)
subcat[2] = new Array('2','筹码',2)
subcat[3] = new Array('2','道具',3)
subcat[4] = new Array('3','血量',1)
function changeselect1(locationid)
{
	document.mapadd_form.map_function.length = 0; //初始化下拉列表 清空下拉数据
	document.mapadd_form.map_function.options[0] = new Option('请选择',''); //给第一个值
	for (i=0; i<subcat.length; i++) //legth=20
	{
	if (subcat[i][0] == locationid) //[0] [1] 第一列 第二列
	{document.mapadd_form.map_function.options[document.mapadd_form.map_function.length] = new Option(subcat[i][1], subcat[i][2]);}
}
}
</script>
[##include file="common/footer.tpl.php"##]